package sevensoft.行为型模式.备忘录模式.黑箱备忘录;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import sevensoft.行为型模式.备忘录模式.白箱备忘录.WordMemento;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Word {

    private String content;

    public WordMemento save() {
        return new WordMemento(content);
    }

    public void recover(Memento memento) {
        WordMemento wordMemento = (WordMemento) memento;
        this.content = wordMemento.getContent();
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    private static class WordMemento implements Memento {
        String content;
    }
}
